package io.gitee.zhangbinhub.acp.core.file.word

import io.gitee.zhangbinhub.acp.core.common.exceptions.EnumValueUndefinedException
import java.util.*

enum class WordType(val value: Int) {
    WORD_TYPE_DOC(0),
    WORD_TYPE_DOCX(1);

    companion object {
        private val map: MutableMap<Int, WordType> = mutableMapOf()

        init {
            for (type in entries) {
                map[type.value] = type
            }
        }

        @Throws(EnumValueUndefinedException::class)
        fun getEnum(value: Int): WordType? {
            if (map.containsKey(value)) {
                return map[value]
            }
            throw EnumValueUndefinedException(WordType::class.java, value.toString() + "")
        }
    }
}
